{[ template "__start__.html" . ]}
<body class="body-signin">
<main id="app" class="w-100 m-auto" style="margin-top: 8px;padding: 24px;">

    <h3>安装</h3>
    <br>
    <div class="form-floating">
        <input type="text" class="form-control" v-model="uuid" id="user" name="user" placeholder="name">
        <label for="user">请输入设备UUID</label>
    </div>
    <div style="margin-top: 8px;">
        <a href="https://www.pgyer.com/tools/udid" style="float: left;" target="_blank">如何获取UUID?</a>
    </div>
    <br>
    <br>
    <hr>
    <template v-if="agree != 1">
        <a class="w-100 btn btn-lg btn-dark" type="submit" @click="uuidPush()">获取下载地址</a>
        <div style="margin-top: 8px;">
            <span>第一次获取后，请等待几分钟后再次点击，将提示您下载</span>
        </div>
    </template>
    <template v-else >
        <a class="w-100 btn btn-lg btn-dark" type="submit" @click="getLink()">下载APP</a>
        <div style="margin-top: 8px;">
            <span>申请中，请稍后点击获取下载地址</span>
        </div>
    </template>
    <br>
    <hr>
    <div style="margin-top: 8px;">
        <span>如何打开开发者模式</span>
    </div>
    <img src="/static/img/ios1.jpg" style="margin: 8px;width: 98%;">

    <img src="/static/img/ios2.jpg" style="margin: 8px;width: 98%;">
    <div style="margin-top: 8px;">
        <span>若没有开发者模式按钮则在：设置-通用-关于本机版本号等信息，连续点击5次，再返回上述页面开发者按钮则会出现</span>
    </div>

    {[ template "__toast__.html" . ]}
</main>
</body>
{[ template "__js__.html" . ]}
<script>
    const { createApp, ref } = Vue;
    const common = new Utils;
    const app = createApp({
        data() {
            return {
                uuid: "",
                agree: 0,
                link: "",
            }
        },
        created:function(){
            let t = this;
            t.getAgree();
        },
        destroyed:function () {
        },
        methods: {
            getAgree: function () {
                let t = this;
                common.AjaxGet("/ios/agree/state", function (resp) {
                    console.log(resp);
                    if (resp.code === 0 ) {
                       t.agree = resp.data.agree;
                       t.uuid = resp.data.uuid;
                    }
                });
            },
            uuidPush: function () {
                let t = this;
                if (t.uuid.length < 10) {
                    common.ToastShow("请输入正确的UDID");
                    return
                }
                common.AjaxGet("/ios/add?uuid="+t.uuid, function (resp) {
                    console.log(resp);
                    if (resp.code === 0) {
                        location.reload();
                    } else {
                        common.ToastShow(resp.msg);
                    }

                });
            },
            getLink: function () {
                let t = this;
                common.AjaxGetNotAsync("/ios/link", function (resp) {
                    console.log(resp);
                    t.link = resp.data.ios_download;
                    window.location=t.link;
                });
            }
        },
        computed: {
        },
        mounted:function(){
        },
    });
    app.mount('#app');
</script>